﻿using System.Threading.Tasks;
using Wx.Sdk.MiniProgram.Entity;

namespace Wx.Sdk.MiniProgram.Src
{
    public interface IMiniProgramLogin
    {
        /// <summary>
        /// 根据客户端回传的code请求解密Key
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        Task<SessionKeyInfo> GetSessionKey(string code);
        /// <summary>
        /// 将客户端的加密数据解析成小程序微信用户
        /// </summary>
        /// <param name="rawData"></param>
        /// <param name="sessionKey"></param>
        /// <returns></returns>
        MiniProgramUser DeCodeUserInfo(RawData rawData, string sessionKey);
        /// <summary>
        /// 获取用户手机号
        /// </summary>
        /// <param name="code">code换取用户手机号。 每个 code 只能使用一次，code的有效期为5min</param>
        /// <returns></returns>
        Task<PhoneInfo> GetUserPhone(string code);
        /// <summary>
        /// 获取加密URLLink
        /// 用于小程序跳转
        /// </summary>
        /// <param name="path">跳转地址</param>
        /// <param name="expire_interval">过期时间，单位天，默认29天</param>
        /// <returns></returns>
        Task<string> GetEncryptedUrlLink(string path, int expire_interval = 29);
    }
}
